package controler.interfaces;

import logs.LogLevelEnum;
import logs.LogTypesEnum;

public abstract class ControlerAbstract implements ControlerInterface {

	protected boolean initOK;
	protected ControlerInterface controler;

	protected String name = "";

	public String getName() {
		return name;
	}

	@Override
	public void init(ControlerInterface controler) {
		this.controler = controler;
		initOK = true;
		logInit();
	}

	// LOGGING
	private void logInit() {
		String log = "";
		if (initOK) {
			log = " (" + this.getName() + ") " + "InitStatus OK";
			controler.log(LogLevelEnum.INFO, LogTypesEnum.Init, log);
		} else {
			log = " (" + this.getName() + ") " + "InitStatus KO";
			controler.log(LogLevelEnum.FATAL, LogTypesEnum.Init, log);
		}
	}


	@Override
	public void log(LogLevelEnum logLevel, LogTypesEnum LogType, String log) {
		controler.log(logLevel, LogType, log);
	}

	public void setName(String name) {
		this.name = name;
	}
	// LOGGING END

}
